package com.dome.base.utils;

import com.dome.auth.utils.UserUtil;
import com.dome.client.entity.po.BaseEntity;

import java.util.Date;

/**
 * 实体初始化通用字段
 */
public class EntityHelper {

    private EntityHelper() {
        throw new AssertionError();
    }

    public static void create(BaseEntity entity) {
        entity.setCreateTime(new Date());
        entity.setCreateUserId(UserUtil.getId());
        entity.setCreateUserName(UserUtil.getUserName());
        entity.setUpdateTime(new Date());
        entity.setUpdateUserId(UserUtil.getId());
        entity.setUpdateUserName(UserUtil.getUserName());
        entity.setIsValid(0);
    }




    public static void update(BaseEntity entity) {
        entity.setUpdateTime(new Date());
        entity.setUpdateUserId(UserUtil.getId());
        entity.setUpdateUserName(UserUtil.getUserName());
    }


}
